1463A - Dungeon - CodeForces Solution


binary search math *1100

Please click on ads to support us..

Python Code:

s = int(input())
sss = []
for i in range(s):
    a,b,c = map(int,input().split())
    r = (a+b+c)//9
    if (a+b+c)%9 == 0 and a >= r and b >= r and c >=r:
        sss.append('YES')
    else:
        sss.append('NO')
print(*sss,sep = '\n')
    

C++ Code:

#include<bits/stdc++.h>
#define ll long long
#define VL vector<ll>
#define loop(i, n) for(int i=0 ; i< n; i++)



using namespace std;
const ll MAX=1e9+10;

//ll binaryExponent(int a , int n){
//	if(n==1) return a;
//	if(n==0) return 1;
//	ll r=binaryExponent(a, n/2);
//	r*=r;
//	if(n%2==0){
//		
//		return r;
//	}else{
//		return (r*a);
//	}
//	
//	
//}

void solve(){
	ll a, b, c;
	cin>>a>>b>>c;
	ll sum=a+b+c;
	ll m=min(a, b);
	m=min(m ,c);
	if(sum%9!=0){
		cout<<"NO\n";
	}else{
		if(m<sum/9) cout<<"NO\n";
		else cout<<"YES\n";
	}	
	
}

int main(){
	
	int t;t=1;
		cin>>t;
	while(t--) solve();
	
	return 0;
}


Comments

Submit
0 Comments
More Questions

1607A - Linear Keyboard
EQUALCOIN Equal Coins
XOREQN Xor Equation
MAKEPAL Weird Palindrome Making
HILLSEQ Hill Sequence
MAXBRIDGE Maximise the bridges
WLDRPL Wildcard Replacement
1221. Split a String in Balanced Strings
1002. Find Common Characters
1602A - Two Subsequences
1555A - PizzaForces
1607B - Odd Grasshopper
1084A - The Fair Nut and Elevator
1440B - Sum of Medians
1032A - Kitchen Utensils
1501B - Napoleon Cake
1584B - Coloring Rectangles
1562B - Scenes From a Memory
1521A - Nastia and Nearly Good Numbers
208. Implement Trie
1605B - Reverse Sort
1607C - Minimum Extraction
1604B - XOR Specia-LIS-t
1606B - Update Files
1598B - Groups
1602B - Divine Array
1594B - Special Numbers
1614A - Divan and a Store
2085. Count Common Words With One Occurrence
2089. Find Target Indices After Sorting Array